package com.superhero.common.repository;

import com.superhero.common.pojo.entity.AccessRegistration;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;


public interface AccessRegistrationRepository extends JpaRepository<AccessRegistration, Integer>, JpaSpecificationExecutor<AccessRegistration> {

    Optional<AccessRegistration> findAccessRegistrationByUserId(Integer userId);

    @Query(nativeQuery = true,value = "SELECT * FROM `access_registration` WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <=DATE(`create_time`) ")
    List<AccessRegistration> findAllInOneWeek();
}
